package cn.edu.scau.cmi.ema.domain;


import java.io.Serializable;

import java.lang.StringBuilder;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.persistence.*;
import javax.xml.bind.annotation.*;
import cn.edu.scau.cmi.ema.domain.*;
import java.util.Set;
import com.alibaba.fastjson.annotation.JSONField;

@Entity
@NamedQueries({
		@NamedQuery(name = "findAllCrawlerfilestandardetails", query = "select myCrawlerfilestandardetail from Crawlerfilestandardetail myCrawlerfilestandardetail"),
		@NamedQuery(name = "findCrawlerfilestandardetailByName", query = "select myCrawlerfilestandardetail from Crawlerfilestandardetail myCrawlerfilestandardetail where myCrawlerfilestandardetail.name = ?1"),
		@NamedQuery(name = "findCrawlerfilestandardetailByNameContaining", query = "select myCrawlerfilestandardetail from Crawlerfilestandardetail myCrawlerfilestandardetail where myCrawlerfilestandardetail.name like concat('%',?1,'%')"),
		@NamedQuery(name = "findCrawlerfilestandardetailByDescription", query = "select myCrawlerfilestandardetail from Crawlerfilestandardetail myCrawlerfilestandardetail where myCrawlerfilestandardetail.description = ?1"),
		@NamedQuery(name = "findCrawlerfilestandardetailByDescriptionContaining", query = "select myCrawlerfilestandardetail from Crawlerfilestandardetail myCrawlerfilestandardetail where myCrawlerfilestandardetail.description like concat('%',?1,'%')"),
		@NamedQuery(name = "findCrawlerfilestandardetailByNumber", query = "select myCrawlerfilestandardetail from Crawlerfilestandardetail myCrawlerfilestandardetail where myCrawlerfilestandardetail.number = ?1"),
		@NamedQuery(name = "findAllCrawlerfilestandardetailsByCrawlerfilestandard", query = "select myCrawlerfilestandardetail from Crawlerfilestandardetail myCrawlerfilestandardetail where myCrawlerfilestandardetail.crawlerfilestandard.id = ?1"),
		@NamedQuery(name = "findAllCrawlerfilestandardetailsByCrawlerfilestandardcolumn", query = "select myCrawlerfilestandardetail from Crawlerfilestandardetail myCrawlerfilestandardetail where myCrawlerfilestandardetail.crawlerfilestandardcolumn.id = ?1"),
		@NamedQuery(name = "findCrawlerfilestandardetailById", query = "select myCrawlerfilestandardetail from Crawlerfilestandardetail myCrawlerfilestandardetail where myCrawlerfilestandardetail.id = ?1"),
		@NamedQuery(name = "findCrawlerfilestandardetailByPrimaryKey", query = "select myCrawlerfilestandardetail from Crawlerfilestandardetail myCrawlerfilestandardetail where myCrawlerfilestandardetail.id = ?1 "),
		@NamedQuery(name = "deleteCrawlerfilestandardetailsByIds", query = "delete Crawlerfilestandardetail where id in (?1)"),
		@NamedQuery(name = "findCrawlerfilestandardetailsByIds", query = "select myCrawlerfilestandardetail from Crawlerfilestandardetail myCrawlerfilestandardetail where myCrawlerfilestandardetail.id in (?1)"),
		@NamedQuery(name = "findCrawlerfilestandardetailByPhyscialPrimaryKey", query = "select myCrawlerfilestandardetail from Crawlerfilestandardetail myCrawlerfilestandardetail where  myCrawlerfilestandardetail.crawlerfilestandard.id = ?1 and myCrawlerfilestandardetail.crawlerfilestandardcolumn.id = ?2 and myCrawlerfilestandardetail.number = ?3"),
		@NamedQuery(name = "countCrawlerfilestandardetailsByName", query = "select count(myCrawlerfilestandardetail)  from Crawlerfilestandardetail myCrawlerfilestandardetail where myCrawlerfilestandardetail.name like concat('%',?1,'%')") })
@Table(catalog = "ema", name = "crawlerfilestandardetail")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "ema/cn/edu/scau/cmi/ema/domain", name = "Crawlerfilestandardetail")
@XmlRootElement(namespace = "ema/cn/edu/scau/cmi/ema/domain")

public class Crawlerfilestandardetail implements Serializable, Comparable<Crawlerfilestandardetail> {

	private static final long serialVersionUID = 1L;

	@Column(name = "id", nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@XmlElement
	Integer id;

	@Column(name = "name")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String name;

	@Column(name = "description")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String description;

	@Column(name = "number")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Integer number;
	@JSONField(serialize = false)
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "crawlerfilestandard", referencedColumnName = "id", nullable = false) })
	@XmlTransient
	Crawlerfilestandard crawlerfilestandard;
	@JSONField(serialize = false)
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "crawlerfilestandardcolumn", referencedColumnName = "id", nullable = false) })
	@XmlTransient
	Crawlerfilestandardcolumn crawlerfilestandardcolumn;

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getId() {
		return this.id;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return this.name;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getDescription() {
		return this.description;
	}

	public void setNumber(Integer number) {
		this.number = number;
	}

	public Integer getNumber() {
		return this.number;
	}

	public void setCrawlerfilestandard(Crawlerfilestandard crawlerfilestandard) {
		this.crawlerfilestandard = crawlerfilestandard;
	}

	public Crawlerfilestandard getCrawlerfilestandard() {
		return crawlerfilestandard;
	}

	public void setCrawlerfilestandardcolumn(Crawlerfilestandardcolumn crawlerfilestandardcolumn) {
		this.crawlerfilestandardcolumn = crawlerfilestandardcolumn;
	}

	public Crawlerfilestandardcolumn getCrawlerfilestandardcolumn() {
		return crawlerfilestandardcolumn;
	}

	public void copy(Crawlerfilestandardetail that) {

		setId(that.getId());

		setName(that.getName());
		setDescription(that.getDescription());
		setNumber(that.getNumber());

		setCrawlerfilestandard(that.getCrawlerfilestandard());

		setCrawlerfilestandardcolumn(that.getCrawlerfilestandardcolumn());

	}

	public Crawlerfilestandardetail() {

	}

	@Override
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("id=[").append(id).append("] ");

		buffer.append("name=[").append(name).append("] ");
		buffer.append("description=[").append(description).append("] ");
		buffer.append("number=[").append(number).append("] ");

		return buffer.toString();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((id == null) ? 0 : id.hashCode()));
		return result;
	}

	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof Crawlerfilestandardetail))
			return false;
		Crawlerfilestandardetail comparedCrawlerfilestandardetail = (Crawlerfilestandardetail) obj;
		if (!CheckPropertyEqual(this.crawlerfilestandard.id, comparedCrawlerfilestandardetail.crawlerfilestandard.id)) {
			return false;
		}
		if (!CheckPropertyEqual(this.crawlerfilestandardcolumn.id,
				comparedCrawlerfilestandardetail.crawlerfilestandardcolumn.id)) {
			return false;
		}
		if (!CheckPropertyEqual(this.number, comparedCrawlerfilestandardetail.number)) {
			return false;
		}
		return true;
	}

	public static <T> boolean CheckPropertyEqual(T originProperty, T comparedProperty) {
		// 基本类型经过参数传递后会自动装箱
		String[] className = originProperty.getClass().getName().split("\\.");
		if (className[0].equals("java") && className[1].equals("math")) {
			return ((Comparable) originProperty).compareTo(comparedProperty) == 0 ? true : false;
		} else {
			return originProperty.equals(comparedProperty);
		}
	}

	@Override
	public int compareTo(Crawlerfilestandardetail o) {
		if (this.getId() > o.getId()) {
			return 1;
		} else if (this.getId() == o.getId()) {
			return 0;
		} else {
			return -1;
		}

	}
}
